package com.itheima.day09;
/*
案例4: 遍历集合
 */

import java.util.ArrayList;

public class TestClassCase04 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();

        Student s1=new Student("张三",21);
        Student s2=new Student("张二",20);
        Student s3=new Student("张一",22);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        for (int i = 0; i < list.size(); i++) {
            Student s=list.get(i);
            if(s.getName()=="张一"){
                s.setAge(19);
            }

            System.out.println("姓名:"+s.getName()+",年龄:"+s.getAge());
        }
    }
}
